var url = location.href;
var title = document.title;
var desc = '';
if (document.getSelection) { desc = document.getSelection(); };

if (desc.toString().length === 0) {
    let descTag = document.querySelector('[name=description]');
    desc = descTag ? descTag.getAttribute('content') : '';
};

if (desc.length > 500) {
    desc = desc.slice(0, 500) + '...';
};

void (
    open('https://cubox.pro/web/tool/collection?url='
        + encodeURIComponent(url)
        + '&title=' + encodeURIComponent(title)
        + '&description=' + encodeURIComponent(desc)
        + '&groupId=' + '&tags=' + '&starTarget=false'
        + '&editable=false', 'cubox', 'toolbar=no,    resizable=no,    location=no,    menubar=no,    width=300,    height=100',
    )
);

/*

https://cubox.pro/web/tool/collection?url=https%3A%2F%2Fcubox.pro%2Fweb%2Fsetting%2Fapps&title=Cubox&description=Cubox 知识库 - 轻松收集、自动整理、深度阅读、灵活管理。帮助你从容面对海量信息，善用网络碎片获得提升。&groupId=&tags=&starTarget=false&editable=false

*/